package com.thrd.taiexhibition.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.facebook.drawee.generic.RoundingParams;
import com.thrd.basicframework.bean.BaseRecyclerAdapter;
import com.thrd.basicframework.utils.TimeUtils;
import com.thrd.taiexhibition.R;
import com.thrd.taiexhibition.bean.BeanHotActivty;
import com.thrd.taiexhibition.fresco.FrescoImage;
import com.thrd.taiexhibition.fresco.FrescoUtils;

import java.util.List;

/**
 * @author: ${唐杰}
 * @date: 2021/3/25
 */
public class CityHotSpotRightAdapter extends BaseRecyclerAdapter<BeanHotActivty> {


    public CityHotSpotRightAdapter(Context context, List<BeanHotActivty> data) {
        super(context, data);
    }

    @Override
    public void bindData(BaseViewHolder holder, BeanHotActivty beanHotActivty) {


        FrescoImage mFrescoImage = (FrescoImage) holder.getView(R.id.fi_image);
        TextView mTitle = (TextView) holder.getView(R.id.tv_title);
        TextView mTime= (TextView) holder.getView(R.id.tv_time);
        TextView mLabel= (TextView) holder.getView(R.id.tv_label);
        TextView mContent= (TextView) holder.getView(R.id.tv_content);

        FrescoUtils.getInstance().setPrefixProgressLoad(getContext(),mFrescoImage,beanHotActivty.getHotActivityCoverImg(),RoundingParams.fromCornersRadius(5f));
        mTitle.setText(TextUtils.isEmpty(beanHotActivty.getHotActivityName())?"":beanHotActivty.getHotActivityName());
        mTime.setText(TextUtils.isEmpty(beanHotActivty.getCreateTime())?"": TimeUtils.getFormatConversion(beanHotActivty.getCreateTime()));
        mContent.setText(TextUtils.isEmpty(beanHotActivty.getHotActivityIntro())?"":beanHotActivty.getHotActivityIntro());

        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(onItemClickListener!=null){
                    onItemClickListener.onImageClickListener(mFrescoImage,beanHotActivty);
                }
            }
        });


    }

    @Override
    public int getItemLayoutId() {
        return R.layout.item_hot_spot_right;
    }


    public  interface OnItemClickListener<T>{
        void onImageClickListener(View view,T t);
    }

    private OnItemClickListener onItemClickListener;

    public OnItemClickListener getOnItemClickListener() {
        return onItemClickListener;
    }

    public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
        this.onItemClickListener = onItemClickListener;
    }
}
